package hc.bre.clas.yesno
import hc.bre.ComponentConfig
import hc.bre.clas.ClasRuleDefinition
import hc.bre.clas.range.*
import hc.bre.cmn.RuleScriptBuilder
import hc.bre.cmn.RuleDefinition

@groovy.transform.CompileStatic
@groovy.transform.ToString(includeNames=true,includePackage=false)
class YesNoDefinition extends ClasRuleDefinition<RangeOption>{
	public static final ComponentConfig _config ;
	static {
		_config = new ComponentConfig();
		_config.rtype = 'rule:clas:yesno';
		_config.rname = '逻辑是否分类';
		_config.builderClass = YesNoBuilder;
		_config.resultStruct = new hc.bre.clas.ClasResultStruct();
		_config.objectpage = '/rule/clas/YesNoEditor.htm?rpath=${rpath}';
		_config.description = '''基于一段脚本的计算结果，做出代表“真/假”、“是/否”含义的二分类。''';
	}

	public static YesNoDefinition create() {
		def ruleDef = new YesNoDefinition();
		ruleDef.list = [
			new RangeOption(id:1,code:'yes',range:'true',name:'是',otherflag:0),
			new RangeOption(id:0,code:'no',range:'false',name:'否',otherflag:1),
		];
		ruleDef.rmaxid = 1;
		return ruleDef;
	}

	String script ='true';

	@Override
	public YesNoDefinition load(Map map) {
		super.load(map);
		script = map['script'];
		return this;
	}
}
